package com.wlyuan.open.scanner.config;

import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Component;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author lijing
 * @description
 */
@Component
@Data
@RefreshScope
public class GroupProperties {

    @Value("${scanner.group}")
    private boolean group;

    @Value("${scanner.groupTenantId}")
    private String groupTenantId;

    public List<Long> groupTenantList() {
        if (!group) {
            return Collections.emptyList();
        }
        return Arrays.asList(groupTenantId.split(",")).stream().map(Long::valueOf).collect(Collectors.toList());
    }
}
